// pages/market/market.js
const globalIp = getApp().globalData.userIp
const zhuzuo = getApp().globalData.zhuzuo
Page({
  /**
   * 页面的初始数据
   */
  data: {
    bannerList:[],
    recipe:[{'_id':'1','recipecover':'http://www.jimei123.com/media/upload/DIY/DIY-LAMINATION3.jpg','recipename':'DIY LAMINATION'},
            {'_id':'4','recipecover':'http://www.jimei123.com/media/upload/series/DIY/2.jpg','recipename':'DIY MAX'},
            {'_id':'7','recipecover':'http://www.jimei123.com/media/upload/series/DIY/1.jpg','recipename':'DIY UDLR'}
    ],
    recipe2:[{'_id':'2','recipecover':'http://www.jimei123.com/media/upload/index/Compress_J_COLORS-2.jpg','recipename':'玫瑰庄园'},
            {'_id':'5','recipecover':'http://www.jimei123.com/media/upload/index/Compress_J_COLORS-1.jpg','recipename':'迷失蔚蓝'},
            {'_id':'8','recipecover':'http://www.jimei123.com/media/upload/index/Compress_J_COLORS-4.jpg','recipename':'咖啡时间'},
            {'_id':'11','recipecover':'http://www.jimei123.com/media/upload/index/Compress_J_COLORS0.jpg','recipename':'默片时代'}
    ],
    recipe3:[{'_id':'3','recipecover':'http://www.jimei123.com/media/upload/2021%20SUMMER%20COLLECTION/JIMEI_UHD_20_Action_UHD_0109_0113_0001_1.jpg','recipename':'图案拼板UHD-S0112'},
            {'_id':'6','recipecover':'http://www.jimei123.com/media/upload/cms_14/2020%20%E7%A7%8B%E5%86%AC%E7%B3%BB%E5%88%97/%E7%BB%8F%E5%85%B8%E7%AF%87/JIMEI_UFQ_6_Delusion_UFQ_0031_0039_0001.jpg','recipename':'基础玳瑁UFQ-0034'},
            {'_id':'9','recipecover':'http://www.jimei123.com/media/upload/2023%20MIDO%20COLLECTION/JIMEI_UC_46_Fleeting_Time_UC2_0282_0289_0001_1.jpg','recipename':'挤板渐变UC2-0285'},
            {'_id':'12','recipecover':'http://www.jimei123.com/media/upload/2023%20MIDO%20COLLECTION/JIMEI_UN_92_Dreamland_UNP_0633_0640_0001_1.jpg','recipename':'挤板单色UNP-0637'}
    ],
    zhuzuo1: zhuzuo
  },

  lookmore: function(e) {
    wx.navigateTo({
      url: '/template/product/webview/webview?id='+e.currentTarget.dataset.id,
    })
  },

  torecipedetail: function(e) {
    // console.log(e.currentTarget.dataset.src)
    wx.previewImage({
      urls: [e.currentTarget.dataset.src], //需要预览的图片http链接列表，注意是数组
      current: '', // 当前显示图片的http链接，默认是第一个
      success: function (res) { },
      fail: function (res) { },
      complete: function (res) { },
    })
  },

  confirm: function() {
    var that = this;
    wx.request({
      url: globalIp + 'home/showLunBo',
      data: {
        type: 'product',
      },
      header: {
        'content-type': 'application/json'
      },
      method: 'POST',
      success: function(res) {
        if (!res.data.success) {
          wx.showToast({
            title: res.data.msg,
            icon: 'none',
            duration: 2000
          })
        } else {
          console.log(res.data)
          that.setData({
            bannerList: res.data.JSONObject.data
          })
        }
      }
    })
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    this.confirm();
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {
    if (typeof this.getTabBar === 'function' &&
      this.getTabBar()) {
      this.getTabBar().setData({
        selected: 1
      })
    }
    this.setData({
      height: wx.getSystemInfoSync().screenHeight * 0.7
    })
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})
